<?php
namespace Home\Controller;
use Think\Controller;
import("Common.Common.Tools");
class DiaryController extends Controller {
    function showlist(){
        $diary=new \Model\DiaryModel();
        $count=$diary->count();
        $page=getpage($count,5);
        $diary_info=$diary->order('id desc')->limit($page->firstRow,$page->listRows)->select();
        $i=0;
        while($diary_info["$i"]!==null){
            $diary_info["$i"]['content']=strip_tags($diary_info["$i"]['content']);
            $i++;
        }
        $show=$page->show();
        $this->assign('diary_info',$diary_info);
        $this->assign('page',$show);
        $link=M('Link');
        $link_info=$link->select();
        $this->assign('link_info',$link_info);
        $this->display();
    }
    function content($id){
        $content=M('Diary');
        $c_info=$content->where("id=$id")->find();
        $info=$content->limit(8)->select();
        $this->assign('info',$info);
        $this->assign('c_info',$c_info);
        $link=M('Link');
        $link_info=$link->limit(8)->select();
        $this->assign('link_info',$link_info);
        $this->display();
    }
}